﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace benefit.Controllers
{
    public class TestController : Controller
    {
        //
        // GET: /Test/

        public ActionResult Index()
        {
            //新浪图片新闻
            System.Net.CookieContainer container = new System.Net.CookieContainer();
            Common.Net.Request request = new Common.Net.Request(container);
            string html = request.ReadUrlContent("http://sports.sina.com.cn/g/2012-01-06/09225896214.shtml", "gb2312");
            html = html.Substring(html.IndexOf("<div class=\"blkContainerSblkCon\" id=\"artibody\">"));
            int imgIndex = html.IndexOf("<div class=\"img_wrapper\">");
            string imgsrc = "";
            if (imgIndex >= 0)
            {
                imgsrc = html;
                imgsrc = imgsrc.Substring(imgsrc.IndexOf("<div class=\"img_wrapper\">") + 25);
                imgsrc = imgsrc.Substring(0, imgsrc.IndexOf("<span"));
                imgsrc.Debug();
            }
            html = html.Substring(0, html.IndexOf("<!-- publish_helper_end -->") + 27);
            int xiangguanIndex = html.IndexOf("<strong>相关</strong>");
            if (xiangguanIndex >= 0)
            {
                html = html.Substring(0, html.IndexOf("<strong>相关</strong>"));
                html += "<!-- publish_helper_end -->";
            }
            html += "</div>";
            ViewBag.Html = html + imgsrc;

            return View();
        }

    }
}
